package com.example.test;

public class Three_Equals {
    public static void main(String[] args) {
        String str = new String("hello");
        if (str=="hello"){
            System.out.println(true);
        }else {
            System.out.println(false);//
        }
        if (str.equals("hello")){
            System.out.println(true);//
        }else {
            System.out.println(false);
        }
        System.out.println("/////////////////////////////////////////");
        Object o = new Object();

        Object oo = new Object();
        System.out.println(o.equals(oo));
        System.out.println(o == oo);
        System.out.println(o.toString().equals(oo.toString()));
        System.out.println("/////////////////////////////////////////");
        String d = new String();
        String h = "";
        String dd = new String();
        String ddd = new String("123456");
        System.out.println(d.equals(dd));
        System.out.println(d == dd);
        System.out.println(d.toString().equals(dd.toString()));
        System.out.println(ddd.toString().equals("123456"));
        System.out.println(ddd=="123456");
        System.out.println("/////////////////////////////////////////比较  “ ” ");
        System.out.println(o.toString().equals(""));
        System.out.println(o.equals(""));
        System.out.println(o=="");
        System.out.println(o.toString() == "");
        System.out.println("/////////////////////////////////////////比较null");
        System.out.println(o.toString().equals(null));
        System.out.println(o.equals(null));
        System.out.println(o==null);
        System.out.println(o.toString() == null);

        //TODO
        System.out.println("/////////////////////////////////////////比较  “ ” ");
        System.out.println(d.toString().equals(""));
        System.out.println(d.equals(""));
        System.out.println(d=="");
        System.out.println(d.toString() == "");

        System.out.println(h.toString().equals(""));
        System.out.println(h.equals(""));
        System.out.println(h=="");
        System.out.println(h.toString() == "");
        System.out.println("/////////////////////////////////////////比较null");
        System.out.println(d.toString().equals(null));
        System.out.println(d.equals(null));
        System.out.println(d==null);
        System.out.println(d.toString() == null);

        System.out.println("/////////////////////////////////////////   使用 equlas 比较null 和 “ ”   会出现空指针");
        String AA= null;
        String a = new String();
        a = null;

        String k = new String();
        k = "";
        System.out.println(AA == "");
        System.out.println(AA == k);
        System.out.println(a == k);
//        System.out.println(AA.equals(""));
//        System.out.println(AA.equals(k));
        System.out.println(a.equals(""));
    }
}
